package com.clanteam.javaking.fic;

import java.util.Iterator;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class FourIsCosmic extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    
        }
    
    @Override
    protected void onPause() {
    	super.onPause();
    	finish();
    }
    
    public void buttonClicked(View view) {
    	EditText entryET = (EditText)findViewById(R.id.entry);
    	TextView resultsTV = (TextView)findViewById(R.id.result);
    	try {
    		List<String> resultList = FourIsCosmicInternal.fourIsCosmic(Long.parseLong(
    				entryET.getText().toString()));
    		String results = new String();
    		for (Iterator<String> iterator = resultList.iterator(); iterator.hasNext();) {
				String string = iterator.next();
				results = results.concat(string+"\n");
			}
    		resultsTV.setText(results);
    	} catch (NumberFormatException nfe) {
    		resultsTV.setText("That number is too big.\n" +
    				"Please input a number and try again");
    	}
    }
}